{% extends 'common.html'%}
    {% block content %}

        <div class="layui-row">
            <form class="layui-form layui-col-md12 we-search">
                <div class="layui-inline">
                    <label class="layui-form-label">输入手机号</label>
                    <div class="layui-input-inline">
                        <input type="tel" id="phone" name="phone" lay-verify="required|phone" autocomplete="off" class="layui-input" >
                    </div>
                </div>

                <button type="button" class="layui-btn" data-type="reload" onclick="return false;">搜索</button>
            </form>
			<div class="smsTable">



            </div>

            <div class="weadmin-block">
				<span class="env_message"></span>
			</div>
        </div>

        <table class="layui-hide" id="table_message" lay-filter="user"></table>


        <script type="text/javascript" src="/static/lib/layui/layui.js" charset="utf-8"></script>

        <script>
            layui.use('table', function(){
                var table = layui.table;

                //方法级渲染
                table.render({
                    elem: '#table_message'
                    ,url: '/sms/message'
                    ,method:'post'
                    ,where: {
                                phone: '',
                                env_tools:parent.window.env_tools
                            }
                    ,cellMinWidth: 100
                    ,cols: [[
                        {checkbox: true, fixed: true}
                        ,{field:'id', title: 'ID', sort: true,width:120, fixed: true}
                        ,{field:'phone', title: '手机号',width:120}
                        ,{field:'content', title: '短信内容',  sort: true}
                        ,{field:'create_time', title: '发送时间',width:160}
                    ]]
                    ,id: 'testReload'
                    ,page: true
                    ,height: 500
                });

                var $ = layui.$, active = {
                    reload: function(){
                        var demoReload = $('#phone');
                        $('.env_message').html('当前操作环境：'+ parent.window.env_tools);
                        //执行重载
                        table.reload('testReload', {
                            page: {
                                curr: 1 //重新从第 1 页开始
                            }
                            ,where: {
                                phone: demoReload.val(),
                                env_tools:parent.window.env_tools
                            }
                        });
                    }
                };

                $('.layui-row .layui-btn').on('click', function(){
                    var type = $(this).data('type');
                    active[type] ? active[type].call(this) : '';

                });
            });
        </script>

    {% endblock %}